<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>BasePage.java</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body {color: #000000; background-color: #ffffff; font-family: Monospaced}
pre {color: #000000; background-color: #ffffff; font-family: Monospaced}
table {color: #000000; background-color: #e9e8e2; font-family: Monospaced}
.ST0 {color: #969696; font-family: Monospaced; font-weight: bold}
.comment {color: #969696}
.line-number {background-color: #e9e8e2}
.character {color: #ce7b00}
.keyword-directive {color: #0000e6}
-->
</style>
</head>
<body>
<table width="100%"><tr><td align="center">C:\GoogleCode\bari\Bari\src\java\dk\jsh\itdiplom\dbsw\bari\wicket\BasePage.java</td></tr></table>
<pre>
<span class="line-number">  1</span> <span class="keyword-directive">package</span> dk.jsh.itdiplom.dbsw.bari.wicket;           
<span class="line-number">  2</span> 
<span class="line-number">  3</span> <span class="keyword-directive">import</span> dk.jsh.itdiplom.dbsw.bari.domain.BariUser;
<span class="line-number">  4</span> <span class="keyword-directive">import</span> dk.jsh.itdiplom.dbsw.bari.domain.Constants.Type;
<span class="line-number">  5</span> <span class="keyword-directive">import</span> java.text.SimpleDateFormat;
<span class="line-number">  6</span> <span class="keyword-directive">import</span> org.apache.wicket.Page;
<span class="line-number">  7</span> <span class="keyword-directive">import</span> org.apache.wicket.markup.html.WebPage;
<span class="line-number">  8</span> <span class="keyword-directive">import</span> org.apache.wicket.markup.html.basic.Label;
<span class="line-number">  9</span> <span class="keyword-directive">i</span><span class="keyword-directive">mport</span> org.apache.wicket.markup.html.link.Link;
<span class="line-number"> 10</span> <span class="keyword-directive">import</span> org.apache.wicket.markup.html.resources.StyleSheetReference;
<span class="line-number"> 11</span> <span class="keyword-directive">import</span> org.apache.wicket.model.Model;
<span class="line-number"> 12</span> <span class="keyword-directive">import</span> org.apache.wicket.model.PropertyModel;
<span class="line-number"> 13</span> 
<span class="line-number"> 14</span> <span class="comment">/**</span> 
<span class="line-number"> 15</span> <span class="comment"> * </span><span class="comment">Abstract</span> <span class="comment">wicket</span> <span class="comment">base</span> <span class="comment">page</span><span class="comment">.</span> <span class="comment">Handles</span> <span class="comment">common</span> <span class="comment">error</span> <span class="comment">message</span> <span class="comment">handling</span><span class="comment">, </span><span class="comment">stylecheet</span>
<span class="line-number"> 16</span> <span class="comment"> * </span><span class="comment">and</span> <span class="comment">menu</span> <span class="comment">links</span><span class="comment">.</span>
<span class="line-number"> 17</span> <span class="comment"> *</span>
<span class="line-number"> 18</span> <span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">Jan</span> <span class="comment">S</span><span class="comment">.</span> <span class="comment">Ha</span><span class="comment">nsen</span>
<span class="line-number"> 19</span>  <span class="comment">*/</span>
<span class="line-number"> 20</span> <span class="keyword-directive">public</span> <span class="keyword-directive">abstract</span> <span class="keyword-directive">class</span> BasePage <span class="keyword-directive">extends</span> WebPage {
<span class="line-number"> 21</span>     <span class="keyword-directive">final</span> <span class="keyword-directive">static</span> SimpleDateFormat standardDateTimeFormat =
<span class="line-number"> 22</span>             <span class="keyword-directive">new</span> SimpleDateFormat(<span class="character">&quot;</span><span class="character">dd/MM-yyyy HH:mm</span><span class="character">&quot;</span>);
<span class="line-number"> 23</span>     <span class="keyword-directive">private</span> String errorMessage = <span class="character">&quot;&quot;</span>;
<span class="line-number"> 24</span>     <span class="keyword-directive">private</span> BariUser bariUser;
<span class="line-number"> 25</span> 
<span class="line-number"> 26</span>     <span class="comment">/**</span>
<span class="line-number"> 27</span> <span class="comment">     * </span><span class="comment">Constructor</span>
<span class="line-number"> 28</span>      <span class="comment">*/</span>
<span class="line-number"> 29</span>     <span class="keyword-directive">public</span> BasePage() {
<span class="line-number"> 30</span>         BariSession bariSession = BariSession.get();
<span class="line-number"> 31</span>         bariUser = bariSession.getBariUser();
<span class="line-number"> 32</span>         <span class="keyword-directive">if</span> (bariUser == <span class="keyword-directive">null</span>) {
<span class="line-number"> 33</span>                 Page loginPage = <span class="keyword-directive">new</span> Login();
<span class="line-number"> 34</span>                 <span class="keyword-directive">this</span>.setResponsePage(loginPage);
<span class="line-number"> 35</span>         }
<span class="line-number"> 36</span>         add(<span class="keyword-directive">new</span> Label(<span class="character">&quot;</span><span class="character">userandrole</span><span class="character">&quot;</span>, <span class="keyword-directive">new</span> Model(bariUser.getFullname() + <span class="character">&quot;</span><span class="character"> som </span><span class="character">&quot;</span>
<span class="line-number"> 37</span>                 + bariUser.getUserRole().getName())));
<span class="line-number"> 38</span> 
<span class="line-number"> 39</span>         PropertyModel errorMessageModel =
<span class="line-number"> 40</span>                 <span class="keyword-directive">new</span> PropertyModel(<span class="keyword-directive">this</span>, <span class="character">&quot;</span><span class="character">errorMessage</span><span class="character">&quot;</span>);
<span class="line-number"> 41</span>         add(<span class="keyword-directive">new</span> Label(<span class="character">&quot;</span><span class="character">error</span><span class="character">&quot;</span>, errorMessageModel));
<span class="line-number"> 42</span>         add(<span class="keyword-directive">new</span> StyleSheetReference(<span class="character">&quot;</span><span class="character">stylesheet</span><span class="character">&quot;</span>, BasePage.<span class="keyword-directive">class</span>, <span class="character">&quot;</span><span class="character">style.css</span><span class="character">&quot;</span>));
<span class="line-number"> 43</span> 
<span class="line-number"> 44</span>         add(<span class="keyword-directive">new</span> Link(<span class="character">&quot;</span><span class="character">createnew</span><span class="character">&quot;</span>) {
<span class="line-number"> 45</span>             @Override
<span class="line-number"> 46</span>             <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> onClick() {
<span class="line-number"> 47</span>                 Page page = <span class="keyword-directive">new</span> CreateNew();
<span class="line-number"> 48</span>                 setResponsePage(page);
<span class="line-number"> 49</span>             }
<span class="line-number"> 50</span>         });
<span class="line-number"> 51</span> 
<span class="line-number"> 52</span>         add(<span class="keyword-directive">new</span> Link(<span class="character">&quot;</span><span class="character">overview</span><span class="character">&quot;</span>) {
<span class="line-number"> 53</span>             @Override
<span class="line-number"> 54</span>             <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> onClick() {
<span class="line-number"> 55</span>                 Page page = <span class="keyword-directive">new</span> Overview(<span class="keyword-directive">null</span>, Type.ERROR, <span class="character">&quot;</span><span class="character">Alle</span><span class="character">&quot;</span>);
<span class="line-number"> 56</span>                 setResponsePage(page);
<span class="line-number"> 57</span>             }
<span class="line-number"> 58</span>         });
<span class="line-number"> 59</span> 
<span class="line-number"> 60</span>         add(<span class="keyword-directive">new</span> Link(<span class="character">&quot;</span><span class="character">logout</span><span class="character">&quot;</span>) {
<span class="line-number"> 61</span>             @Override
<span class="line-number"> 62</span>             <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> onClick() {
<span class="line-number"> 63</span>                 BariSession bariSession = BariSession.get();
<span class="line-number"> 64</span>                 bariSession.setBariUser(<span class="keyword-directive">null</span>);
<span class="line-number"> 65</span>                 Page page = <span class="keyword-directive">new</span> Login();
<span class="line-number"> 66</span>                 setResponsePage(page);
<span class="line-number"> 67</span>             }
<span class="line-number"> 68</span>         });
<span class="line-number"> 69</span> 
<span class="line-number"> 70</span>         add(<span class="keyword-directive">new</span> Link(<span class="character">&quot;</span><span class="character">about</span><span class="character">&quot;</span>) {
<span class="line-number"> 71</span>             @Override
<span class="line-number"> 72</span>             <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> onClick() {
<span class="line-number"> 73</span>                 Page page = <span class="keyword-directive">new</span> About();
<span class="line-number"> 74</span>                 setResponsePage(page);
<span class="line-number"> 75</span>             }
<span class="line-number"> 76</span>         });
<span class="line-number"> 77</span>     }
<span class="line-number"> 78</span> 
<span class="line-number"> 79</span>     <span class="comment">/**</span>
<span class="line-number"> 80</span> <span class="comment">     * </span><span class="comment">Get</span> <span class="comment">BaRI</span> <span class="comment">user</span><span class="comment">.</span>
<span class="line-number"> 81</span>      <span class="comment">*/</span>
<span class="line-number"> 82</span>     <span class="keyword-directive">public</span> BariUser getBariUser() {
<span class="line-number"> 83</span>         <span class="keyword-directive">return</span> bariUser;
<span class="line-number"> 84</span>     }
<span class="line-number"> 85</span> 
<span class="line-number"> 86</span>     <span class="comment">/**</span>
<span class="line-number"> 87</span> <span class="comment">     * </span><span class="comment">Set</span> <span class="comment">BaRI</span> <span class="comment">user</span><span class="comment">.</span>
<span class="line-number"> 88</span>      <span class="comment">*/</span>
<span class="line-number"> 89</span>     <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> setBariUser(BariUser bariUser) {
<span class="line-number"> 90</span>         <span class="keyword-directive">t</span><span class="keyword-directive">his</span>.bariUser = bariUser;
<span class="line-number"> 91</span>     }
<span class="line-number"> 92</span> 
<span class="line-number"> 93</span>     <span class="comment">/**</span>
<span class="line-number"> 94</span> <span class="comment">     * </span><span class="comment">Returns</span> <span class="comment">an</span> <span class="comment">error</span> <span class="comment">message</span>
<span class="line-number"> 95</span>      <span class="comment">*/</span>
<span class="line-number"> 96</span>     <span class="keyword-directive">public</span> String getErrorMessage() {
<span class="line-number"> 97</span>         <span class="keyword-directive">return</span> errorMessage;
<span class="line-number"> 98</span>     }
<span class="line-number"> 99</span> 
<span class="line-number">100</span>     <span class="comment">/**</span>
<span class="line-number">101</span> <span class="comment">     * </span><span class="comment">Set</span> <span class="comment">error</span> <span class="comment">message</span><span class="comment">.</span>
<span class="line-number">102</span>      <span class="comment">*/</span>
<span class="line-number">103</span>     <span class="keyword-directive">public</span> <span class="keyword-directive">void</span> setErrorMessage(String errorMessage) {
<span class="line-number">104</span>         <span class="keyword-directive">this</span>.errorMessage = errorMessage;
<span class="line-number">105</span>     }
<span class="line-number">106</span> }
<span class="line-number">107</span> 
</pre></body>
</html>
